#include <SoftwareSerial.h>

const int LEDGREEN = 3;

const int LEDRED1 = 13;
const int LEDRED2 = 12;
const int LEDRED4 = 11;
const int LEDRED8 = 10;

SoftwareSerial mySerial(7,6); // RX, TX

int inByte = 0;
 
void setup()
{
  //Open the serial port
  Serial.begin(9600); 
  mySerial.begin(9600);
  
  //Set the digital pin as output
  pinMode(LEDRED1, OUTPUT);
  pinMode(LEDRED2, OUTPUT);
  pinMode(LEDRED4, OUTPUT);
  pinMode(LEDRED8, OUTPUT);
  pinMode(LEDGREEN, OUTPUT);
  
  
}
 
void loop(){
 
    if(Serial.available() > 0)
    {
      inByte = Serial.read(); //read the incoming byte
      switch (inByte) {
        case 'A'://0
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'B'://1
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'C'://2
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'D'://3
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'E'://4
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'F'://5
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'G'://6
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'H'://7
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, LOW);
        break;
        case 'I'://8
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'J'://9
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'K'://10
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'L'://11
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, LOW);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'M'://12
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'N'://13
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, LOW);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'O'://14
        digitalWrite(LEDRED1, LOW);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, HIGH);
        break;
        case 'P'://15
        digitalWrite(LEDRED1, HIGH);
        digitalWrite(LEDRED2, HIGH);
        digitalWrite(LEDRED4, HIGH);
        digitalWrite(LEDRED8, HIGH);
        break;
      }
      mySerial.write(inByte);
    }
    if(mySerial.available() > 0)
    {
      inByte = mySerial.read(); //read the incoming byte
      if(inByte=='0')
      {
        digitalWrite(LEDGREEN, LOW);
        Serial.write(inByte);
      }
      else if(inByte=='1')
      {
        digitalWrite(LEDGREEN, HIGH);
      Serial.write(inByte);
    }
  }                  
}
